import coin.base.database.util as db_util
from xunkemgmt.tool.strat_monitor.database.memcached_querier import MemcachedStrategySummaryQuerier

db_config = db_util.read_db_config('../../coin_deploy/support_pta/config/memcached_config_iosg.json')
querier = MemcachedStrategySummaryQuerier(db_config)
strat_summary_messages = querier.query_strategy_summary_history()
for strat_summary_message in strat_summary_messages:
  for summary in strat_summary_message.summaries:
    for account_id, account_stat in summary.stat_per_account.items():
      for symbol, symbol_stat in account_stat.stat_per_symbol.items():
        print(f'machine: {summary.process.machine}, strategy_name: {summary.strategy.strategy_name}, symbol: {symbol}, currency: {symbol_stat.accounting_currency}, pnl_from_fill: {symbol_stat.pnl_mark_from_fill}, pnl_from_fill_in_usd: {symbol_stat.pnl_mark_from_fill_in_usd}')
